using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;

namespace BUS
{
  public  class CTDealBUS
    {
        
         public static void Insert(CTDeal ctdeal)
        {
            CTDealDAL ctdealDAL = new CTDealDAL();
           ctdealDAL.Insert(ctdeal);
        }
        public static void Update(CTDeal ctdeal)
        {
            CTDealDAL ctdealDAL = new CTDealDAL();
            ctdealDAL.Update(ctdeal);
        }
        public static void Delete(int iD)
        {
            CTDealDAL ctdealDAL = new CTDealDAL();
            ctdealDAL.Delete(iD);
        }
        public static tbCTDealCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            CTDealDAL ctdealDAL = new CTDealDAL();
            return ctdealDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDealDAL ctdealDAL = new CTDealDAL();
            return ctdealDAL.Get(cri.Criter, 0, 0, tbCTDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static CTDeal GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbCTDealColumns.MaDeal.ToString(), Condition.EQUAL, iD);
           CTDealDAL ctdealDAL = new CTDealDAL();
           tbCTDealCollection chitietdealcollection = ctdealDAL.Get(cri.Criter,
                 0, 0, tbCTDealColumns.MaDeal.ToString(), OrderDirection.ASC.ToString(), out total);
           if (chitietdealcollection.Count > 0)
               return chitietdealcollection[0];
           return null;
       }
      
        public static tbCTDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDealDAL ctdealDAL = new CTDealDAL();
            return ctdealDAL.Get(cri.Criter, 1, number,
             tbCTDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCTDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDealDAL ctdealDAL = new CTDealDAL();
            return ctdealDAL.Get(cri.Criter, 1, number,
               tbCTDealColumns.MaDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    
    
}
